#include<bits/stdc++.h>
using namespace std;
int main(){
	string str,user;
	char c;
	int n;
	map<string ,string> a;
	cin>>n;
	for( int i = 0 ; i < n ; i++ ){
		cin>>c;
		cin>>user>>str;
		map<string ,string >::iterator it;;
		it=a.find(user);
		if(c=='L'){
			if(it==a.end()){
				cout<<"ERROR: Not Exist"<<endl;
			}
			else if(it!=a.end()&&str!=a[user]){
				cout<<"ERROR: Wrong PW"<<endl;
			}
			else if(it!=a.end()&&str==a[user]){
				cout<<"Login: OK"<<endl;
			}
		}
		else {
			if(it==a.end()){
				a[user]=str;
				cout<<"New: OK"<<endl;
			}
			else{
				cout<<"ERROR: Exist"<<endl;
			}
		}
	}
}
